"""
@File    ：page_repair_escalation.py
@Author  ：ixiaodu
@Date    ：2024/8/20
@Desc    ：
"""
import allure
from common.page_base import Base
from page_element import el_repair_escalation
from utils.timer import sleep


class PageRepairEscalation(Base):
    """维修上报页面"""

    def click_add_repair(self):
        """点击添加维修"""
        self.base_click(el_repair_escalation.add_repair)
        sleep()

    def click_repair_type(self):
        """点击维修类型"""
        self.base_click(el_repair_escalation.repair_type)
        sleep()

    def click_repair_type_value(self):
        """点击维修类型值"""
        self.base_click(el_repair_escalation.repair_type_value)
        sleep()

    def input_repair_content(self, content):
        """输入维修内容"""
        self.base_input(el_repair_escalation.repair_content, content)
        sleep()

    def click_repair_img_upload(self):
        """点击维修图片"""
        self.base_click(el_repair_escalation.repair_img)
        sleep()
        self.processing_image_upload()

    def click_repair_submit(self):
        """点击维修提交"""
        self.base_click(el_repair_escalation.repair_submit)
        sleep()

    def click_repair_submit_affirm(self):
        """点击维修提交确认"""
        self.base_click(el_repair_escalation.repair_submit_affirm)
        sleep()

    def get_response_info(self):
        """获取响应信息"""
        sleep()
        return self.base_get_text(el_repair_escalation.response_info)

    def click_done(self):
        """点击已完成"""
        self.base_click(el_repair_escalation.done)
        sleep()

    def click_repair_detail(self):
        """点击报修详情"""
        self.base_click(el_repair_escalation.repair_detail)
        sleep()

    def click_repair_evaluation(self):
        """点击报修评价"""
        self.base_click(el_repair_escalation.repair_evaluation)
        sleep()

    def select_star_number(self):
        """选择星数"""
        self.base_click(el_repair_escalation.star_number)
        sleep()

    def select_smile_face(self):
        """选择笑脸表情"""
        self.base_click(el_repair_escalation.smile_face)
        sleep()

    def select_crying_face(self):
        """选择哭脸表情"""
        self.base_click(el_repair_escalation.crying_face)
        sleep()

    def input_evaluation_content(self, content):
        """输入评价内容"""
        self.base_input(el_repair_escalation.evaluation_content, content)
        sleep()

    def upload_evaluation_img(self):
        """上传评价图片"""
        self.base_click(el_repair_escalation.evaluation_img)
        sleep()
        self.processing_image_upload()

    def select_settle_type(self):
        """选择解决类型"""
        self.base_click(el_repair_escalation.settle_type)
        sleep()

    def click_evaluation_submit(self):
        """点击评价提交"""
        self.base_click(el_repair_escalation.evaluation_submit)
        sleep()

    def get_repair_status(self):
        """获取报修状态"""
        sleep()
        return self.base_get_text(el_repair_escalation.repair_status)

    def add_repair(self, content):
        """新增报修"""
        with allure.step("点击新增报修"):
            self.click_add_repair()
        with allure.step("点击维修类型"):
            self.click_repair_type()
        with allure.step("选择维修类型值"):
            self.click_repair_type_value()
        with allure.step(f"报修内容输入{content}"):
            self.input_repair_content(content)
        with allure.step("点击选择图片"):
            self.click_repair_img_upload()
        with allure.step("点击提交按钮"):
            self.click_repair_submit()
        with allure.step("确认提交"):
            self.click_repair_submit_affirm()

    def add_repair_evaluation(self, content):
        """新增报修评价"""
        with allure.step("点击已完成"):
            self.click_done()
        with allure.step("点击报修详情"):
            self.click_repair_detail()
        with allure.step("点击报修评价"):
            self.click_repair_evaluation()
        with allure.step("选择星数"):
            self.select_star_number()
        with allure.step("选择笑脸表情"):
            self.select_smile_face()
        with allure.step("选择哭脸表情"):
            self.select_crying_face()
        with allure.step("输入评价内容"):
            self.input_evaluation_content(content)
        with allure.step("上传评价图片"):
            self.upload_evaluation_img()
        with allure.step("选择解决类型"):
            self.select_settle_type()
        with allure.step("点击评价提交"):
            self.click_evaluation_submit()
